{% extends 'base/base.html' %}
{% load static %}
{% block title %}管理员仪表盘{% endblock %}

{% block extra_css %}
<link rel="stylesheet" href="{% static 'css/admin.css' %}">
{% endblock %}

{% block sidebar %}
<div class="sidebar-sticky pt-3">
    <ul class="nav flex-column">
        <li class="nav-item">
            <a class="nav-link active" href="{% url 'admin_dashboard' %}">
                <i class="fas fa-tachometer-alt me-2"></i>仪表盘
            </a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="{% url 'user_list' %}">
                <i class="fas fa-users me-2"></i>用户管理
            </a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="{% url 'culture_list' %}">
                <i class="fas fa-building me-2"></i>文旅机构
            </a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="{% url 'spot_review_list' %}">
                <i class="fas fa-map-marked-alt me-2"></i>景点审核
            </a>
        </li>
    </ul>
</div>
{% endblock %}

{% block content %}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
    <h1 class="h2">管理员仪表盘</h1>
</div>

<div class="row mb-4">
    <div class="col-md-4">
        <div class="card text-white bg-primary mb-3">
            <div class="card-body">
                <h5 class="card-title">用户总数</h5>
                <p class="card-text display-4">{{ user_count }}</p>
            </div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card text-white bg-success mb-3">
            <div class="card-body">
                <h5 class="card-title">文旅机构</h5>
                <p class="card-text display-4">{{ culture_count }}</p>
            </div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card text-white bg-warning mb-3">
            <div class="card-body">
                <h5 class="card-title">待审景点</h5>
                <p class="card-text display-4">{{ pending_spots }}</p>
            </div>
        </div>
    </div>
</div>

<div class="card">
    <div class="card-header">
        <h5>最新待审核景点</h5>
    </div>
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th>景点名称</th>
                        <th>提交机构</th>
                        <th>提交时间</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {% for spot in latest_spots %}
                    <tr>
                        <td>{{ spot.name }}</td>
                        <td>{{ spot.created_by.culture_profile.institution_name }}</td>
                        <td>{{ spot.created_at|date:"Y-m-d H:i" }}</td>
                        <td>
                            <a href="{% url 'accounts:review_spot' spot.id %}" class="btn btn-sm btn-primary">审核</a>
                        </td>
                    </tr>
                    {% empty %}
                    <tr>
                        <td colspan="4" class="text-center">暂无待审核景点</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}

{% block extra_js %}
<script src="{% static 'js/admin.js' %}"></script>
{% endblock %}